//package com.gr.catanddog_web.filter;
//
//
//import jakarta.servlet.*;
//import jakarta.servlet.annotation.WebFilter;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//@Component
//@WebFilter("/*")
//public class CrosFilter implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        System.out.println(request.getHeader("token"));
//        filterChain.doFilter(servletRequest, servletResponse);
//        /*HttpServletResponse response = getHttpServletResponse((HttpServletResponse) servletResponse);
//        // 如果是跨域预检请求,则直接在此响应200
//        if(request.getMethod().equalsIgnoreCase("OPTIONS")){
//            //WebUtil.writeJson(response, Result.ok(null));
//            response.setStatus(200);
//        }else{
//            // 非预检请求,放行即可
//            filterChain.doFilter(servletRequest, servletResponse);
//        }*/
//    }
//    public static HttpServletResponse getHttpServletResponse(HttpServletResponse servletResponse) {
//        HttpServletResponse response = servletResponse;
//        response.setHeader("Access-Control-Allow-Headers","token");
//        response.setHeader("token","Content-Type");
//        response.setHeader("Access-Control-Allow-Origin", "*");
//        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE, HEAD");
//        response.setHeader("Access-Control-Max-Age", "3600");
//        response.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
//        response.setHeader("Set-Cookie", "JSESSIONID=0B16B281C505A572009FC7D7C359C1A9;Expires=7; Path=/; HttpOnly; Secure=True; SameSite=None");
//        return response;
//    }
//    @Override
//    public void destroy() {
//    }
//}
